"""
广播发送
"""
from socket import *
from time import sleep

# 广播地址
dest = ('192.168.5.255', 9999)
s = socket(AF_INET, SOCK_DGRAM)

# 设置可以发送广播
s.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)

data = """
    我在学python 如何发送广播
"""

while True:
    sleep(2)
    s.sendto(data.encode(), dest)
s.close()
